//https://leetcode.cn/problems/powx-n/

class Solution {
public:
    double myPow(double x, int n)
    {
        return n < 0 ? 1 / Pow(x, -(long long)n) : Pow(x, n);
    }

    double Pow(double x, long long n)
    {
        if (n == 0) return 1;

        double temp = Pow(x, n / 2);

        return n % 2 == 0 ? temp * temp : temp * temp * x;
    }
};